package config

// 错误码定义
const (
	ECReqNormal = 0

	// 通用错误[1-100]
	ECLoginInvalid = 1

	// 注册[101-200]
	ECRegisterPhonenumTypeError = 101
	ECRegisterPasswordTypeError = 102
	ECRegisterUseridRepeat      = 103
	ECRegisterIdcardTypeError   = 104

	// 登录[201-300]
	ECLoginUseridError    = 201
	ECLoginPasswordError  = 202

	// 商城[301-400]
	ECShopVersionLow        = 301
	ECShopNotExist          = 302
	ECShopClientVersionLow  = 303
	ECShopPaytypeError      = 304
	ECShopMoneyNotEnough    = 305
)

// 错误信息
var ErrorMessages = map[int]string{
	ECReqNormal:                    "请求处理正常",
	ECLoginInvalid:                 "请先进行登录",
	ECRegisterPhonenumTypeError:    "手机号格式错误，请重新输入",
	ECRegisterPasswordTypeError:    "密码格式错误，请重新输入",
	ECRegisterUseridRepeat:         "该账号已被注册",
	ECRegisterIdcardTypeError:      "身份证号格式错误，请重新输入",
	ECLoginUseridError:             "账号不存在，请重新输入",
	ECLoginPasswordError:           "密码错误，请重新输入",
	ECShopVersionLow:               "商城版本过低，请刷新重试",
	ECShopNotExist:                 "该道具不存在",
	ECShopClientVersionLow:         "客户端版本过低，请更新后重试",
	ECShopPaytypeError:             "不支持当前选择支付方式",
	ECShopMoneyNotEnough:           "余额不足，请及时充值",
}

// GetErrorMessage 获取错误信息
func GetErrorMessage(code int) string {
	if msg, ok := ErrorMessages[code]; ok {
		return msg
	}
	return "未知错误"
}


